package com.kt.jdk7;

import com.kt.
ExceptionsKt;
import com.kt.Metadata
;
import com.kt.jvm.functions.Function1;

@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u001c\n\u0000\n\u0002\u0010\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0003\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0002\u001a\u0018\u0010\u0000\u001a\u00020\u0001*\u0004\u0018\u00010\u00022\b\u0010\u0003\u001a\u0004\u0018\u00010\u0004H\u0001\u001aH\u0010\u0005\u001a\u0002H\u0006\"\n\b\u0000\u0010\u0007*\u0004\u0018\u00010\u0002\"\u0004\b\u0001\u0010\u0006*\u0002H\u00072\u0012\u0010\b\u001a\u000e\u0012\u0004\u0012\u0002H\u0007\u0012\u0004\u0012\u0002H\u00060\tH\bø\u0001\u0000\u0002\n\n\b\b\u0001\u0012\u0002\u0010\u0001 \u0001¢\u0006\u0002\u0010\n\u0002\u0007\n\u0005\b20\u0001¨\u0006\u000b"}, d2 = {"closeFinally", "", "Ljava/lang/AutoCloseable;", "cause", "", "use", "R", "T", "block", "Lkotlin/Function1;", "(Ljava/lang/AutoCloseable;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;", "kotlin-stdlib-jdk7"}, k = 2, mv = {1, 4, 0}, pn = "kotlin")
/* compiled from: AutoCloseable.kt */
public final class AutoCloseableKt {
    /* JADX WARNING: Code restructure failed: missing block: B:10:0x001a, code lost:
        com.kt.jvm.internal.InlineMarker.finallyStart(1);
        closeFinally(r4, r3);
        com.kt.jvm.internal.InlineMarker.finallyEnd(1);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:11:0x0023, code lost:
        throw r3;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:9:0x0019, code lost:
        r3 = move-exception;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private static final <T extends AutoCloseable, R> R use(T r4, Function1<? super T, ? extends R> r5) {
        /*
            r0 = 0
            r1 = 0
            java.lang.Throwable r1 = (java.lang.Throwable) r1
            r2 = 1
            java.lang.Object r3 = r5.invoke(r4)     // Catch:{ all -> 0x0015 }
            com.kt.jvm.internal.InlineMarker.finallyStart(r2)
            closeFinally(r4, r1)
            com.kt.jvm.internal.InlineMarker.finallyEnd(r2)
            return r3
        L_0x0015:
            r3 = move-exception
            r1 = r3
            throw r3     // Catch:{ all -> 0x0019 }
        L_0x0019:
            r3 = move-exception
            com.kt.jvm.internal.InlineMarker.finallyStart(r2)
            closeFinally(r4, r1)
            com.kt.jvm.internal.InlineMarker.finallyEnd(r2)
            throw r3
        */
        throw new UnsupportedOperationException("Method not decompiled: com.kt.jdk7.AutoCloseableKt.use(java.lang.AutoCloseable, com.kt.jvm.functions.Function1):java.lang.Object");
    }

    public static final void closeFinally(AutoCloseable $this$closeFinally, Throwable cause) {
        if ($this$closeFinally != null) {
            if (cause == null) {
                try {
                    $this$closeFinally.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return;
            }
            try {
                $this$closeFinally.close();
            } catch (Throwable closeException) {
                ExceptionsKt.addSuppressed(cause, closeException);
            }
        }
    }
}
